/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package pe.edu.pucp.dp1.TSPSolution.view;

/**
 *
 * @author walter
 */
public class Frm_RegistrarServicio extends javax.swing.JPanel {

    /**
     * Creates new form Frm_RegistrarServicio
     */
    public Frm_RegistrarServicio() {
        initComponents();
    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jPanel1 = new javax.swing.JPanel();
        lblNombre = new javax.swing.JLabel();
        txtNombre = new javax.swing.JTextField();
        txtPorcSobreCosto = new javax.swing.JTextField();
        lblPorcSobreCosto = new javax.swing.JLabel();
        btnRegistrarServicio = new javax.swing.JButton();
        btnCancelarRegServicio = new javax.swing.JButton();
        btnLimpiarRegServicio = new javax.swing.JButton();

        jPanel1.setBorder(javax.swing.BorderFactory.createTitledBorder("Registrar Servicio"));

        lblNombre.setText("Nombre");

        txtPorcSobreCosto.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                txtPorcSobreCostoActionPerformed(evt);
            }
        });

        lblPorcSobreCosto.setText("Porc. sobre costo");

        btnRegistrarServicio.setText("Registrar");
        btnRegistrarServicio.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseReleased(java.awt.event.MouseEvent evt) {
                btnRegistrarServicioMouseReleased(evt);
            }
        });

        btnCancelarRegServicio.setText("Cancelar");
        btnCancelarRegServicio.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseReleased(java.awt.event.MouseEvent evt) {
                btnCancelarRegServicioMouseReleased(evt);
            }
        });

        btnLimpiarRegServicio.setText("Limpiar");
        btnLimpiarRegServicio.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseReleased(java.awt.event.MouseEvent evt) {
                btnLimpiarRegServicioMouseReleased(evt);
            }
        });

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(lblNombre)
                    .addComponent(lblPorcSobreCosto)
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addGap(38, 38, 38)
                        .addComponent(btnRegistrarServicio)))
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addGap(21, 21, 21)
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(txtNombre)
                            .addComponent(txtPorcSobreCosto))
                        .addContainerGap())
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 27, Short.MAX_VALUE)
                        .addComponent(btnLimpiarRegServicio)
                        .addGap(38, 38, 38)
                        .addComponent(btnCancelarRegServicio)
                        .addGap(44, 44, 44))))
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(lblNombre)
                    .addComponent(txtNombre, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(lblPorcSobreCosto)
                    .addComponent(txtPorcSobreCosto, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(btnCancelarRegServicio)
                    .addComponent(btnRegistrarServicio)
                    .addComponent(btnLimpiarRegServicio))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
        this.setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addContainerGap())
        );
    }// </editor-fold>//GEN-END:initComponents

    private void txtPorcSobreCostoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_txtPorcSobreCostoActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_txtPorcSobreCostoActionPerformed

    private void btnRegistrarServicioMouseReleased(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_btnRegistrarServicioMouseReleased
        // TODO add your handling code here:
        String nombre = txtNombre.getText() ;
        int porcSobreCosto = Integer.parseInt( txtPorcSobreCosto.getText() ) ;
        registrarServicio( nombre , porcSobreCosto ) ;
    }//GEN-LAST:event_btnRegistrarServicioMouseReleased

    private void registrarServicio( String nombre , int porcSobreCosto ){
        // mostrar mensaje de exito
        limpiar() ;
    }
    
    private void limpiar(){
        txtNombre.setText( "" ) ;
        txtPorcSobreCosto.setText( "" ) ;
    }
    
    private void btnLimpiarRegServicioMouseReleased(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_btnLimpiarRegServicioMouseReleased
        // TODO add your handling code here:
        limpiar() ;
    }//GEN-LAST:event_btnLimpiarRegServicioMouseReleased

    private void cerrar(){
        this.setVisible( false ) ;
    }
    
    private void btnCancelarRegServicioMouseReleased(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_btnCancelarRegServicioMouseReleased
        // TODO add your handling code here:
        cerrar() ;
    }//GEN-LAST:event_btnCancelarRegServicioMouseReleased

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton btnCancelarRegServicio;
    private javax.swing.JButton btnLimpiarRegServicio;
    private javax.swing.JButton btnRegistrarServicio;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JLabel lblNombre;
    private javax.swing.JLabel lblPorcSobreCosto;
    private javax.swing.JTextField txtNombre;
    private javax.swing.JTextField txtPorcSobreCosto;
    // End of variables declaration//GEN-END:variables
}
